//
//  ZdqNetWork.m
//  DLT-daluntai
//
//  Created by Apple on 17/3/21.
//  Copyright © 2017年 BW. All rights reserved.
//

#import "ZdqNetWork.h"

@implementation ZdqNetWork

    
+(void)getWithURLString:(NSString *)urlString parameters:(id)parameters success:(SuccessBlock)successBlock failure:(FailureBlock)failureBlock{
    
    AFHTTPSessionManager *manager=[AFHTTPSessionManager manager];
    /**
     * 可以接受的类型
     *
     */
    manager.responseSerializer=[AFHTTPResponseSerializer serializer];
    /**
     *  请求队列的最大并发数
     */
    //    manager.operationQueue.maxConcurrentOperationCount = 5;
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval=outline;
    [manager GET:urlString parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        if(successBlock){
            NSDictionary *dic=[responseObject objectFromJSONData];
            successBlock(dic);
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        if (failureBlock) {
            failureBlock(error);
            NSLog(@"网络异常 ~\(≧▽≦)/~ 请检查网络链接 %@ ",error);
        }
    }];
  
}
    
    
+(void)postWithURLString:(NSString *)urlString parameters:(id)parameters success:(SuccessBlock)successBlock failure:(FailureBlock)failureBlock{
    
    AFHTTPSessionManager *manager=[AFHTTPSessionManager manager];
    manager.responseSerializer=[AFHTTPResponseSerializer serializer ];
    manager.requestSerializer.timeoutInterval=outline;
    [manager POST:urlString parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        if (successBlock) {
            NSDictionary *dic=[responseObject objectFromJSONData];
            successBlock(dic);
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        if (failureBlock) {
            failureBlock(error);
            NSLog(@"网络异常 ~\(≧▽≦)/~ 请检查网络链接 %@ ",error);
        }
    }];
    
}
    
    
    
    
@end
